Skip to content

knowledge: reject foreign records in a source-snapshot pack - #463

Merged
amy-why-3459 merged 1 commit into
InferMatrixLab:mainfrom
Dong1017:codex/issue355-snapshot-pack-guard
Nov 16, 2026
Merged

amy-why-3459 merged 1 commit into
InferMatrixLab:mainfrom
Dong1017:codex/issue355-snapshot-pack-guard

Conversation

@Dong1017

Copy link
Copy Markdown
Collaborator

Follow-up to #359, addressing the two non-blocking questions on catalog.py in the re-review.

Problem

inferrsi.knowledge.catalog resolves schema-2 records in a pack that has _provenance.json, but still accepts any other JSON file there. On main f5362887:

  • A schema-1 record mixed into a source-snapshot pack is read as an ordinary record. It keeps its own source pin and bypasses the shared snapshot without any error.
  • A _provenance.json copied into a subdirectory is read as a record and rejected only as "Incomplete knowledge record", which hides what went wrong.

Change

  • src/inferrsi/knowledge/catalog.py: in a pack that has _provenance.json, any JSON record that is not schema 2 is rejected with a message naming the pack and path. Only the root _provenance.json is the snapshot. Packs without a snapshot keep their hand-written schema-1 records unchanged.
  • tests/test_source_snapshot.py: one test builds a pack with the real snapshot and one stored record, then checks that it loads, that a nested _provenance.json is rejected, and that a resolved schema-1 record in the same pack is rejected. Without the catalog change, the nested case fails with the "incomplete" message and the schema-1 case is accepted.
  • docs/knowledge-contribution-workflow.md: one sentence stating the rule.

No generated record, generator or skill-library file changes, so this PR does not touch the shared snapshot or coverage view that knowledge PRs regenerate.

The re-review's other notes need no code change here: main's workflow doc already states that the declaration path lists overlap, and the manual re-pin after a squash merge is listed under its limits.

Verification

At head 9ce122749cb37fbe9b19fbe2cbc7ed13d6b3670d over main f536288710c726a827bfa3e4357c2c911984cbc3:

  • tests/test_source_snapshot.py and tests/test_knowledge_tiers.py: 28 passed, exit 0 (Python 3.13, Windows).
  • ruff check src tests tools with ruff 0.17.5, the version CI installed for Extend VLA observation-to-action benchmark guidance #342 on the same day, and git diff --check pass.
  • tools/knowledge_declaration_paths.py --base upstream/main --head HEAD reports one protected path, src/inferrsi/knowledge/catalog.py, and no generated paths.

Hosted Python 3.10/3.11 full and installed-package checks are the full-suite evidence.

Refs #355.

Knowledge authorship declaration

{
  "schema_version": 1,
  "head_sha": "9ce122749cb37fbe9b19fbe2cbc7ed13d6b3670d",
  "human_only": false,
  "material_ai_authors": [
    {
      "tool": "Claude Code",
      "model_id": "claude-opus-5-5",
      "effort": "xhigh",
      "role": "author"
    }
  ]
}

A pack with _provenance.json holds only generated schema-2 records. The
catalog now rejects any other JSON record there, including a schema-1 record
mixed into the pack and a _provenance.json copied into a subdirectory, which
was previously read as an incomplete record. Packs without a snapshot keep
their hand-written schema-1 records.

Follows the review questions on InferMatrixLab#359. Refs InferMatrixLab#355.

Agent-assisted-by: Claude Code / claude-opus-5-5 [effort=xhigh] (author)
Signed-off-by: Dong1017 <55723162+Dong1017@users.noreply.github.com>
@Dong1017 Dong1017 added area:knowledge Knowledge line: packs, skill library, knowledge admission kind:task Bounded delivery task with a delegated slice labels Nov 16, 2026
@Dong1017

Copy link
Copy Markdown
Collaborator Author

@amy-why-3459 @zengchuang-hw ready for review at 9ce122749cb37fbe9b19fbe2cbc7ed13d6b3670d. This answers the two non-blocking catalog.py questions from your #359 re-review:

  1. Stray _provenance.json in a subdirectory. Only the root manifest is the snapshot. A nested copy now fails with a message naming the path, instead of "Incomplete knowledge record".
  2. Mixed schema-1 and schema-2 records. A pack that has _provenance.json now accepts only schema-2 records. On main f5362887 a schema-1 record in such a pack is accepted silently with its own source pin. Packs without a snapshot keep their hand-written schema-1 records.

One new test covers both cases; it fails on main without the catalog.py change. The PR touches no generated record, so it does not conflict with knowledge PRs that regenerate the shared snapshot.

CI at this head is green: full-check (3.10, 3.11), installed-package (3.10, 3.11), pr-references and dashboard-browser; declarations and knowledge-model-policy also pass.

@amy-why-3459 amy-why-3459 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

PR review verdict — PASS
Reviewed base f536288 and head 9ce1227.
Verified a source-snapshot pack (_provenance.json present) now rejects any JSON file that is not schema 2, including a nested _provenance.json and a resolved schema-1 record, with an error that names the pack and path (src/inferrsi/knowledge/catalog.py). Packs without a snapshot are unchanged. tests/test_source_snapshot.py covers the load path and both rejections; docs/knowledge-contribution-workflow.md states the rule. This addresses the two non-blocking catalog.py questions from the #359 re-review (#359 (comment)).
Hosted full-check (3.10 and 3.11), installed-package, declarations, pr-references and dashboard-browser are green on this head. Accuracy and performance comparison experiments are not applicable: this is a catalog validation guard plus tests and a doc sentence, with no model-output or performance claim.

@zengchuang-hw zengchuang-hw left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

PR review verdict — PASS

Independent first review for the request in #463 (comment), acting through zengchuang-hw under the account holder's standing InferRSI review/Approve delegation. Reviewed base f536288 → head 9ce1227. No previous review by this account on this PR.

Read the actual three-file diff, catalog traversal/validation, source-snapshot resolution, contribution contract and governing #355 accepted representation. The catalog rejects non-schema-2 records in snapshot-backed packs before normal validation, while retaining root-only manifest skipping, schema-2-to-public-schema-1 resolution and snapshot-free schema-1 packs. The regression exercises the valid root snapshot, a nested manifest and a resolved schema-1 record in a generated pack. No blocking defect found.

Executed in an isolated checkout at this head:

  • 58 tests passed across test_source_snapshot, test_knowledge_contract, test_knowledge_tiers and test_knowledge_cli.
  • git diff --check passed.
  • Independently checked current-head hosted full-check and installed-package jobs for Python 3.10/3.11, dashboard-browser, declarations and pr-references: all success.

Not run locally: full suite, clean-wheel installation, browser tests, Python 3.10/3.11 matrix or Ruff (Ruff unavailable in this local environment; hosted full-check passed). No hardware/model performance or campaign acceptance claim.

Resolved items: the two catalog boundary behaviors are now explicit and regression-tested. Approval-before items: none for this bounded change. Non-blocking suggestions: none. No merge performed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:knowledge Knowledge line: packs, skill library, knowledge admission kind:task Bounded delivery task with a delegated slice

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants